package com.manlitech.manlichat.controller;

import com.manlitech.manlichat.base.netty.handler.MyWebSocketHandler;
import com.manlitech.manlichat.base.netty.message.container.MessageHandler;
import com.manlitech.manlichat.base.netty.message.container.MessageHandlerContainer;
import com.manlitech.manlichat.pojo.Result;
import com.manlitech.manlichat.util.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/ws/test")
public class TestController {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    MessageHandlerContainer messageHandlerContainer;

    @Autowired
    MyWebSocketHandler myWebSocketHandler;
    /**
     * 测试请求返回
     * @return
     */
    @ApiOperation(value="测试Api请求", notes="验证请求是否正常")
    @RequestMapping(value="/test", method= RequestMethod.GET)
    public Result test() {
        logger.info("进入测试");
        logger.debug("debug");
        logger.trace("trace");
        logger.error("error");
        MessageHandler messageHandler = messageHandlerContainer.getMessageHandler("CHAT_TO_ONE_REQUEST");
        if(myWebSocketHandler == null){
            logger.error("123");
        }else{
            logger.info("success");
        }
        return ResultUtil.success("HELLO MANLi");
    }

}